<template>
  <div>
    <div v-if="typeof(showType)==='undefined'">
      <!--是否有组标题-->
      <el-tag color="#2b85e4" style="color:white;margin-left:10px;margin-bottom:20px" size="large"
              v-if="formAttr.groupTitle!='undefined' && formAttr.groupTitle!=null && formAttr.groupTitle!=''">
        {{formAttr.groupTitle}}
      </el-tag>
      <!--定义表单布局，目前定义一行两个或是三个-->
      <el-row :gutter="10">
        <el-col :span="24/cols" v-for="item in formAttr.items">
          <lemon-e-form-item :item-attr="item" :label-width="formAttr.labelWidth"
                             :width="formAttr.width"></lemon-e-form-item>
        </el-col>
      </el-row>
    </div>
    <div v-else-if="showType=='collapse'">
      <el-collapse v-model="activeCollapse" accordion>
        <el-collapse-item :name="formAttr.groupTitle">
          <template slot="title">
            <fort style="font-size: 15px"><strong>{{formAttr.groupTitle}}</strong></fort>
          </template>
          <el-row :gutter="20">
            <el-col :span="24/cols" v-for="item in formAttr.items">
              <lemon-e-form-item :item-attr="item" :label-width="formAttr.labelWidth"
                                 :width="formAttr.width"></lemon-e-form-item>
            </el-col>
          </el-row>

        </el-collapse-item>
      </el-collapse>
    </div>
  </div>
</template>

<style lang="scss">

</style>

<script>
  import LemonEFormItem from './LemonEFormItem'

  export default {
    name: 'LemonEForm',
    components: {LemonEFormItem},
    props: {

      /*
        formAttr:{groupTitle:'',items:[]}
      */
      showType: String,
      formAttr: Object,
      cols: Number
    },
    data() {
      return {
        activeCollapse: ''
      }
    }
  }
</script>
